﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using log4net;
using System.Reflection;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace AnyOffice.general.info.post_no
{
    public partial class search : ModulePage
    {
        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string str = (Request.Form["area"] != null) ? Request.Form["area"].ToString() : "";
                string str2 = (Request.Form["post_no"] != null) ? Request.Form["post_no"].ToString() : "";
                string commandText = string.Empty;
                SqlParameter[] commandParameters = new SqlParameter[1];
                if (str != string.Empty)
                {
                    commandText = "SELECT * FROM Post_Tel WHERE Area=@Area";
                    commandParameters[0] = new SqlParameter("@Area", str);
                }
                else
                {
                    commandText = "SELECT * FROM Post_Tel WHERE PostNO=@PostNO";
                    commandParameters[0] = new SqlParameter("@PostNO", str2);
                }
                if (commandText == string.Empty)
                {
                    this.pnlMain.Visible = false;
                    this.litMessage.Text = base.ShowPrompt("没有符合条件的结果");
                }
                else
                {
                    DataTable table = SqlHelper.ExecuteDataset(base.Conn, CommandType.Text , commandText, commandParameters).Tables[0];
                    if (table.Rows.Count > 0)
                    {
                        this.rptPostNo.DataSource = table;
                        this.rptPostNo.DataBind();
                    }
                    else
                    {
                        this.pnlMain.Visible = false;
                        this.litMessage.Text = base.ShowPrompt("没有符合条件的结果");
                    }
                }
            }
            catch (Exception exception)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("", exception);
                }
            }
        } 

    }
}
